<!-- $Id: user_analysis_order_amount.htm 2015-10-27 13:41:21Z langlibin $ -->
{if $full_page}
{include file="pageheader_bd.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}
<script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />

<div id="tabbar-div">
    <p>
        <span class="tab-back" onclick="javascript:location.href='user_added_stats.php'">新增会员</span>
        <span class="tab-front" onclick="javascript:location.href='user_analysis_order_count.php'">会员分析</span>
        <span class="tab-back" onclick="javascript:location.href='user_analysis_scale.php'">会员规模分析</span>
        <span class="tab-back" onclick="javascript:location.href='user_area_stats.php'">区域分布</span>
    </p>
</div>
<div class="main-div">
    <p style="margin: 10px">
        1、符合以下任何一种条件的订单即为有效订单：1、采用在线支付方式支付并且已付款；2、采用货到付款方式支付并且交易已完成<br />
        2、列表展示了时间段内所有会员有效订单的订单数量、下单商品数量和订单总额统计数据，并可以点击列表上方的“导出数据”，将列表数据导出为Excel文件<br />
    </p>
</div>
<div class="form-div">
    <form action="user_analysis_order_amount.php" method="post" id="searchForm" name="searchForm">
        <select name="stats_type" id="stats_type" onchange="week()">
            <option value="0" {if $stats_type eq '0'}selected{/if}>按日统计</option>
            <option value="1" {if $stats_type eq '1'}selected{/if}>按周统计</option>
            <option value="2" {if $stats_type eq '2'}selected{/if}>按月统计</option>
        </select>
        <input name="date" id="date" value="{$date}" style="width:100px;height:20px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
        <select name="year" id="year" onchange="week()"></select>
        <select name="month" id="month" onchange="week()"></select>
        <select name="dropweek" id="dropweek" {if $stats_type neq '1'}style="display: none"{/if}></select>
        &nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value="{$lang.query}" class="button" />
        <input type="submit" name="export" id="export" value="导出数据" class="button" onclick="" />
    </form>
</div>
<div id="tabbar-div2">
    <p>
        <span class="tab-back" onclick="javascript:location.href='user_analysis_order_count.php'">下单量</span>
        <span class="tab-back" onclick="javascript:location.href='user_analysis_goods_count.php'">下单商品数</span>
        <span class="tab-front" onclick="javascript:location.href='user_analysis_order_amount.php'">下单金额</span>
    </p>
</div>
<div class="list-div" id="order_list_1">
    <div class="order_count">
        <p><span class="tab_front">买家排行TOP15</span></p>
        <div style='height:400px;width:90%;margin-left:auto;margin-right:auto;' id='orders_option_div_1'></div>
    </div>
</div>

<form method="POST" action="user_analysis_order_amount.php" name="listForm" onsubmit="">
    <div class="list-div" id="listDiv">
        {/if}

        <table cellpadding="3" cellspacing="1">
            <tr>
                <th>序号</th>
                <th>会员名称</th>
                <th>下单金额</th>
            </tr>
            {foreach from=$result_list item=item}
            <tr>
                <td>{$item.no}</td>
                <td>{$item.user_name}</td>
                <td>{$item.order_count}</td>
            </tr>
            {foreachelse}
            <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
            {/foreach}
        </table>

        <table cellpadding="4" cellspacing="0">
            <tr>
                <td align="right">{include file="page.htm"}</td>
            </tr>
        </table>

        {if $full_page}
    </div>
</form>

<script type="text/javascript" language="JavaScript">
    listTable.recordCount = {$record_count};
    listTable.pageCount = {$page_count};

    {foreach from=$filter item=item key=key}
    listTable.filter.{$key} = '{$item}';
    {/foreach}

</script>
<script type="text/javascript" language="JavaScript">
    var date = new Date();
    var y = date.getFullYear();
    var m = date.getMonth() + 1;

    for (i = 0; i < 10; i++) {
        var oP = document.createElement("option");
        var oText = document.createTextNode(y);
        oP.appendChild(oText);
        oP.setAttribute("value", y);
        if(y == '{$year}')
        {
            oP.setAttribute("selected", "selected")
        }
        document.getElementById('year').appendChild(oP);
        y = y - 1;
    };
    var j = 1;
    for (i = 1; i < 13; i++) {
        var month = document.createElement("option");
        var monthText = document.createTextNode(j);
        month.appendChild(monthText);
        month.setAttribute("value", j);
        if (j == {$month})
        {
            month.setAttribute("selected", "selected");
        }
        document.getElementById('month').appendChild(month);
        j = j + 1;
    };

    var week_num = {$week_num};
    //绑定周
    function week()
    {
        if($("#stats_type").val()==0)
        {
            $("#date").show();
            $("#year").hide();
            $("#month").hide();
            $("#dropweek").hide();
            return;
        }
        else if($("#stats_type").val()==2)
        {
            $("#date").hide();
            $("#year").show();
            $("#month").show();
            $("#dropweek").hide();
            return;
        }
        $("#date").hide();
        $("#year").show();
        $("#month").show();
        $("#dropweek").show();
        var text = $("#year").val() + '-' + $("#month").val();
        var ymd = text.substring(0, 4) + "-" + text.substring(5, 7) + "-1";
        var week = new Date(Date.parse(ymd.replace(/\-/g, "/")));
        var w = week.toString().substring(0, 3);
        var yymm = new Date(text.substring(0, 4), text.substring(5, 7), 0);
        var day = yymm.getDate();
        var dd = 1;
        switch (w) {
            case "Mon": dd = 0; break;
            case "Tue": dd = 1; break;
            case "Wed": dd = 2; break;
            case "Thu": dd = 3; break;
            case "Fri": dd = 4; break;
            case "Sat": dd = 5; break;
            case "Sun": dd = 6; break;
        }
        var aw = 5;
        if (day == 28 && dd == 0) {
            aw = 4;
        }
        var i = 1;
        $("#dropweek").empty();
        for (var i = 0; i < aw; i++) {
            var start = i * 7 + 1 - dd;
            var end = i * 7 + 7 - dd;
            if (start < 1) {
                start = 1;
            }
            if (end > day) {
                end = day;
            }
            var str = ("第" + (i + 1) + "周 <" + text.substring(5, 7) + "月" + start + "号—" + text.substring(5, 7) + "月" + end + "号>").toString();
            var val = $("#year").val() + '-' + text.substring(5, 7) + '-' + start + ' ' + $("#year").val() + '-' + text.substring(5, 7) + '-' + end + ' ' + i;
            $("#dropweek").append("<option value='" + val + "'>" + str + "</option>");
        }
        $('#dropweek')[0].selectedIndex = week_num;

        var itme = $("#dropweek").find("option:selected").text();
        $("#txtweek:text").val(itme.toString());
    }
    // 执行
    week();
</script>
<script src='js/echarts-all.js'></script>
<script>
    var option1 = {
        title : {
//            text: '某地区蒸发量和降水量',
//            subtext: '纯属虚构'
        },
        tooltip : {
            trigger: 'axis'
        },
        legend: {
            data:['']
        },
        toolbox: {
            show : true,
            feature : {
                mark : {show: false},
                dataView : {show: false, readOnly: false},
                magicType : {show: true, type: ['bar']},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : true,
        xAxis : [
            {
                type : 'category',
                data : [{$user_no_arr}]
            }
        ],
        yAxis : [
            {
                type : 'value',
                axisLabel : {
                    formatter: '{value} 元'
                }
            }
        ],
        series : [
            {
                name:'下单金额',
                type:'bar',
                data:[{$order_count_arr}],
                markPoint : {
                    data : [
//                        {name : '年最高', value : 182.2, xAxis: 7, yAxis: 183, symbolSize:18},
//                        {name : '年最低', value : 2.3, xAxis: 11, yAxis: 3}
                    ]
                },
                markLine : {
                    data : [
//                        {type : 'average', name : '平均值'}
                    ]
                }
            }
        ]
    };
    var order_chart1 = echarts.init(document.getElementById('orders_option_div_1'));
    order_chart1.setOption(option1);
</script>
{include file="pagefooter.htm"}
{/if}